package cn01;

import java.util.Random;
import java.util.Scanner;

public class test11 {
    public static void main(String[] args) {
        Random r = new Random();
        int a = r.nextInt(100);
        int count = 0;
        while (true) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入你要猜的数字：");
            int i = sc.nextInt();
            if (i > a) {
                System.out.println("猜的大了");
            } else if (i < a) {
                System.out.println("猜的小了");
            } else {
                System.out.println("恭喜你 猜对了");
                break;
            }
            count++;
        }
        System.out.println("总共猜了"+count+"次");
    }
}
